import java.util.Scanner;

public class d086 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int knowledge = 'K' + 'N' + 'O' + 'W' + 'L' + 'E' + 'D' + 'G' + 'E' - 576; //:Output : 96
		final int hardwork = 'H' + 'A' + 'R' + 'D' + 'W' + 'O' + 'R' + 'K' - 512; //:Output : 98
		final int attitude = 'A' + 'T' + 'T' + 'I' + 'T' +'U' + 'D' + 'E' - 512; //:Output : 100
		
		String input, output = "";
		int sum_char;
		boolean englishOX;
		
		while(sc.hasNext()) {
			englishOX = true;
			sum_char = 0;
			
			if(sc.hasNextInt()) {
				input = Integer.toString(sc.nextInt());				
				if(Integer.parseInt(input) == 0) {
					return;
				} else {
					sum_char = Integer.parseInt(input);
					englishOX = false;
				}
			}
			
			input = sc.nextLine();
			
			if(englishOX) {
				for(int i = 0; i < input.length(); i++) {
					if(input.charAt(i) >= 65 && input.charAt(i) <= 90 || input.charAt(i) >= 97 && input.charAt(i) <= 122) {
						sum_char += Character.toUpperCase(input.charAt(i)) - 64;					
					} else {
						englishOX = false;
					}
				}
			}			

			if(englishOX) {
				output = Integer.toString(sum_char);
			} else {
				output = "Fail";
			}
			
			System.out.println(output);
		} // next
	} // main
		
}